package cn.shangtour.scenery.service;

import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;


import cn.shangtour.common.pojo.Scenery;
import cn.shangtour.common.vo.SceneryUIResult;
import cn.shangtour.scenery.mapper.SceneryMapper;

@Service
public class SceneryService {
	@Autowired
	private SceneryMapper sceneryMapper;
//景点查询
	@RequestMapping
	public SceneryUIResult sceneryPageQuery(Integer page, Integer rows) {
		//封装对象
		SceneryUIResult result = new SceneryUIResult();
		//封装属性
		Integer total = sceneryMapper.queryTotal();
		//封装属性
		Integer start=(page-1)*rows;
		List<Scenery> pList=sceneryMapper.queryByPage(start,rows);
		//封装对象属性
		result.setTotal(total);
		result.setRows(pList);
		return result;
	}
//单景点查询	
	public Scenery queryById(String sceneryId) {
		return sceneryMapper.queryById(sceneryId) ;
	}
//新增景点
	public void scenerySave(Scenery scenery) {
		scenery.setSceneryId(UUID.randomUUID().toString());
		sceneryMapper.scenerySave(scenery);
	}
//景点更新
	public void sceneryUpdate(Scenery scenery) {
		sceneryMapper.sceneryUpdate(scenery);
	}

}
